

package com.dog.basics.admin.controller.wishwash.admin;

import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.wishwash.AdminDogHxFieldAddDto;
import com.dog.basics.bean.dto.admin.wishwash.AdminDogHxFieldEditDto;
import com.dog.basics.bean.dto.admin.wishwash.AdminDogHxFieldFromDto;
import com.dog.basics.bean.vo.admin.wishwash.AdminDogHxFieldVo;
import com.dog.basics.bean.vo.admin.wishwash.AdminDogHxFieldInfoVo;

import com.dog.basics.bean.model.wishwash.DogHxField;
import com.dog.basics.service.wishwash.DogHxFieldService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 场地信息
 *
 * @author cy code generator
 * @date 2021-07-09 17:40:28
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/doghxfield" )
@Api(value = "场地信息管理", tags = "场地信息管理")
public class DogHxFieldController {

    private final  DogHxFieldService dogHxFieldService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param obj 场地信息
     * @return
     * @author cy code generator
     * @date 2021-07-09 17:40:28
     */
    @ApiOperation(value = "分页查询", notes = "admin_doghxfield_view")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('admin_doghxfield_view')" )
    public R<IPage<AdminDogHxFieldVo>> getDogHxFieldPage(PageParam page, AdminDogHxFieldFromDto obj) {
        return R.ok(dogHxFieldService.getAdminPageList(page,obj));
    }


    /**
     * 通过id查询场地信息
     * @param id id
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:28
     */
    @ApiOperation(value = "通过id查询", notes = "admin_doghxfield_info")
    @GetMapping("/{id}" )
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    @PreAuthorize("@pms.hasPermission('admin_doghxfield_info')" )
    public R<AdminDogHxFieldInfoVo> getById(@PathVariable("id" ) Long id) {
        return R.ok(dogHxFieldService.getAdminObjXq(id));
    }

    /**
     * 新增场地信息
     * @param obj 场地信息
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:28
     */
    @ApiOperation(value = "新增场地信息", notes = "admin_doghxfield_add")
    @SysLog("新增场地信息" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('admin_doghxfield_add')" )
    public R<Boolean>  save(@Valid  @RequestBody AdminDogHxFieldAddDto obj) {
        return R.ok(dogHxFieldService.saveAdminObj(obj));
    }

    /**
     * 修改场地信息
     * @param obj 场地信息
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:28
     */
    @ApiOperation(value = "修改场地信息", notes = "admin_doghxfield_edit")
    @SysLog("修改场地信息" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('admin_doghxfield_edit')" )
    public R<Boolean> updateById(@Valid  @RequestBody AdminDogHxFieldEditDto obj) {
        return R.ok(dogHxFieldService.editAdminObj(obj));
    }

    /**
     * 通过id删除场地信息
     * @param id id
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:28
     */
    @ApiOperation(value = "通过id删除场地信息", notes = "admin_doghxfield_del")
    @SysLog("通过id删除场地信息" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('admin_doghxfield_del')" )
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    public R<Boolean>  removeById(@PathVariable Long id) {
        return R.ok(dogHxFieldService.deleteObj(id));
    }

}
